Skip to content

[RFQ] Add maxRetrySeconds configuration and RetryTooLong exception #307

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

schaudhry123
Copy link

RFQ: Add maxRetrySeconds configuration and RetryTooLong exception

Summary

This PR implements the maxRetrySeconds configuration parameter and RetryTooLong exception to limit retry wait times for the Zscaler SDK, addressing ticket SZ-1.

Changes Made

1. Configuration (zscaler/config/config_setter.py)

  • Added maxRetrySeconds parameter to the rateLimit configuration section
  • Default value is 0 (meaning unlimited retry time)
  • Added to both _DEFAULT_CONFIG and _apply_default_values method

2. Exception Class (zscaler/exceptions/exceptions.py)

  • Created new RetryTooLong exception class
  • Includes retry_seconds and max_seconds properties
  • Descriptive error message showing both actual and maximum retry times

3. Request Executor (zscaler/request_executor.py)

  • Added validation in constructor to ensure maxRetrySeconds >= 0
  • Modified fire_request_helper method to check backoff time against limit
  • Logs warning before throwing RetryTooLong exception
  • Only applies limit when maxRetrySeconds > 0 (0 means unlimited)
  • Check applies to all retryable status codes (408, 409, 412, 429, 500, 502, 503, 504)

4. Module Exports (zscaler/__init__.py)

  • Exported RetryTooLong exception for easy import

Usage Example

from zscaler import ZscalerClient, RetryTooLong

with ZscalerClient(
    config={
        "client": {
            "rateLimit": {
                "maxRetrySeconds": 50
            }
        }
    }
) as client:
    try:
        results = client.zcc.devices.list_device()
    except RetryTooLong:
        print("Retry time is too long.")

Testing

  • ✅ All configuration changes verified
  • ✅ Exception class properties and message tested
  • ✅ RequestExecutor validation tested
  • ✅ Import functionality verified
  • ✅ Build verification passed with poetry build

Implementation Details

  • The feature only activates when maxRetrySeconds > 0
  • Warning is logged before throwing the exception
  • Applies to all retryable HTTP status codes, not just 429
  • Maintains backward compatibility (default value 0 = unlimited)

Jira Ticket: SZ-1
Link to Devin run: https://app.devin.ai/sessions/d0e3dce18ac34f3badb1e989d3d98256
Requested by: Samir Chaudhry (samir@cognition.ai)

- Add maxRetrySeconds parameter to rateLimit config with default value 0
- Create RetryTooLong exception with retry_seconds and max_seconds properties
- Add validation in RequestExecutor constructor for maxRetrySeconds >= 0
- Implement retry time limit check in fire_request_helper method
- Log warning before throwing RetryTooLong exception
- Export RetryTooLong exception in main module
- Only apply limit when maxRetrySeconds > 0 (0 means unlimited)
- Check applies to all retryable status codes (408, 409, 412, 429, 500, 502, 503, 504)

Fixes: SZ-1

Co-Authored-By: Samir Chaudhry <schaudhry123@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant